require "UI/Main/main_model"
local _MainView = require "UI/Main/main_view"

MainController = MainController or BaseClass()
local MainController = MainController

function MainController:__init()
	-- MainController.Instance = self
	self.model = MainModel:GetInstance()
	self:initEvent()
end

function MainController:GetInstance()
	if MainController.Instance == nil then
		MainController.Instance = MainController.New()
		-- MainController.New()
	end
	return MainController.Instance
end

function MainController:initEvent()
	local function onOpenMainView()
		if self.main_view == nil then
			self.main_view = _MainView.New()
		end
		self.main_view:Open()
	end
	self.model:Bind(MainModel.EVENT_NAME.OPEN_MAIN_VIEW, onOpenMainView)
	onOpenMainView()
end

return MainController